package com.zhxy.manager.controller;



import com.zhxy.manager.entity.Library;
import com.zhxy.manager.service.intf.LibraryService;
import com.zhxy.manager.vo.PageBean;
import com.zhxy.manager.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/api/library/")
public class LibraryController {
    @Autowired
    private LibraryService service;

    //新增
    @RequestMapping("save.do")
    public R save(Library library){
        return service.save(library);
    }
    //查询
    @GetMapping("page.do")
    public PageBean page(int page, int limit){

        return service.queryPage(page, limit);
    }
    //条件查询
    @GetMapping("pagewhere.do")
    public PageBean page(String bookname,int page,int limit){
        return service.queryPageWhere(bookname,page,limit);
    }
    //删除
    @PostMapping("del.do")
    public R del(int id){
        return  service.del(id);
    }
    //修改
    @PostMapping("update.do")
    public R update(Library library){
        return service.update(library);
    }
    //批量删除 JSON格式的数据请求
    @PostMapping("delbatch.do")
    public R del(@RequestBody int[] ids){
        return service.delBatch(ids);
    }
}
